package com.smh.a06comprehensiveExercises;

public class Test2 {
    public static void main(String[] args) {

        String s = "100000000";

        String regex = "([1-9][\\d]{0,9})|[\\d]";
//        Pattern pattern = Pattern.compile(regex);
//        Matcher m = pattern.matcher(s);
        if (!s.matches(regex)){
            System.out.println("数据格式有错误");
        }else {
            int num =0;
            char[] arr = s.toCharArray();
            for (int i = 0; i < arr.length; i++) {
                //num+=(arr[i]-'0')*Math.pow(10,arr.length-i-1);
                num=num*10+(arr[i]-'0');
            }
            System.out.println(num);
        }

    }
}
